package com.bc.web.controller.merch;



import com.bc.web.model.MerchUser;
import com.fs.common.extend.FSController;
import com.fs.common.util.FSMD5;

public class MerchUserController extends FSController{
	
	public void index(){
		setAttr("sidebar", getSession().getAttribute("sidebar"));
		render("index.html");
	}
	
	public void changePasswordPage(){
		render("changePassword.html");
	}
	
	public void changePassword(){
		String userId = getPara("userId");
		String oldPassword = getPara("oldPassword");
		String newPassword = getPara("newPassword");
		MerchUser user = MerchUser.dao.findById(userId);
		if(user.getPassword().equalsIgnoreCase(FSMD5.codeFor(oldPassword))){
			user.setPassword(FSMD5.codeFor(newPassword));
			user.update();
			renderSuccess("修改密码成功.");
		}else{
			renderFail("旧密码错误.");
		}
	}

}
